def check(train, max_seat, l, r):
    for i in range(l, r):
        if train[i] >= max_seat:
            return False
    return True


def dfs(pass_info, train, value, ans, idx, m):
    if idx == len(pass_info):
        ans[0] = max(ans[0], value)
        return
    l, r = pass_info[idx]
    dfs(pass_info, train, value, ans, idx + 1, m)
    if check(train, m, l, r):
        for i in range(l, r):
            train[i] += 1
        dfs(pass_info, train, value + r - l, ans, idx + 1, m)


m, n, x = map(int, input().split())
pass_info = [list(map(int, input().split())) for _ in range(x)]
ans = [0]
train = [0] * n
dfs(pass_info, train, 0, ans, 0, m)
print(ans[0])
